/* PO replication code 
Chung and Pechenkina ``Testing the effects of group-affirmation in active conflict:
 Ukrainians' trust toward Russia" PLOS ONE
April 12, 2022

Harvard Dataverse: https://doi.org/10.7910/DVN/UX7QMC
*/


cd "/Users/..../CP_PLOSONE_replication/"
use "CP_PLOSONE_replication_april2022.dta" 


/** Table 1: Breakdown of answers when careless and insufficient effort (C/IE) responses  
are defined as three consecutive identical values in the outcome measures **/

*Column 1: Total assigned

**Row 1: OIA
tab assigned_to_OI_v_control if assigned_to_OI_v_control==1

**Row 2: NIA
tab assigned_to_NIA_v_control if assigned_to_NIA_v_control==1

**Row 3: Control
tab assigned_to_OI_v_control assigned_to_NIA_v_control


*Column 2: Total quality responses = assigned minus C/IE

**Row 1: OIA
tab assigned_to_OI_v_control if assigned_to_OI_v_control==1 & longstring3==0

**Row 2: NIA
tab assigned_to_NIA_v_control if assigned_to_NIA_v_control==1 & longstring3==0

**Row 3: Control
tab assigned_to_OI_v_control assigned_to_NIA_v_control if  longstring3==0

*Columns 3, 4, 5, 6: Passed MC,	Failed MC,	Hard to say,	Refused to answer

**Row 1: OIA
tab assigned_to_OI_v_control b17_1_treatmt_made_think_abt
tab assigned_to_OI_v_control b17_1_treatmt_made_think_abt if longstring3==0

**Row 2: NIA
tab assigned_to_NIA_v_control b17_1_treatmt_made_think_abt
tab assigned_to_NIA_v_control b17_1_treatmt_made_think_abt if longstring3==0

**Row 3: Control
tab assigned_to_OI_v_control b17_3_control_made_think_abt
tab assigned_to_OI_v_control b17_3_control_made_think_abt if longstring3==0


**Column 7: No engagement with MC

**Row 1: OIA
*a. obtain total engagement for OIA = 527
tab assigned_to_NIA_v_control b17_1_treatmt_made_think_abt if longstring3==0
*b. subtract from total quality assigned, i.e., 598
*598-527=71

**Row 2: NIA
*a. obtain total engagement for NIA = 529
tab assigned_to_NIA_v_control b17_1_treatmt_made_think_abt if longstring3==0
*b. subtract from total quality assigned, i.e., 582
*582-529=53

**Row 3: Control
*a. obtain total engagement for NIA = 411 
tab assigned_to_OI_v_control b17_3_control_made_think_abt if longstring3==0
*b. subtract from total quality assigned, i.e., 590
*590-411=179


/** Table 2: Descriptive statistics **/


/*gen passed_def2_long3 = 0
replace passed_def2_long3 = 1 if 	treat_oi_passed_MC1!=. &longstring3==0
replace passed_def2_long3 = 1 if 	treat_nia_passed_MC1!=. &longstring3==0
*/

** This is the sample used in the main paper
tab passed_def2_long3

estpost sum dv_trustgov_std dv_trustrusppl_std dv_trust_all4_std treat_oi_passed_MC1 treat_nia_passed_MC1 ///
sd1_female sd2_age education income region_southeast b12_therm_russia polpref_zelensky_party polpref_none ///
occuptn_professional occuptn_retired settlement_type convenient_rus ethn_rus if passed_def2_long3==1
esttab using cp_descriptive_tableA_control_def2.tex, replace label cell((count mean sd min max sum)) nonumber nomtitle

esttab using cp_descriptive_table2.tex, replace label cell((count mean sd min max sum)) nonumber nomtitle
	
esttab using cp_descriptive_table2.doc, replace label cell((count mean sd min max sum)) nonumber nomtitle
	
/** Table 3: Differences in trust between treated and control units **/
	**t-tests
	
** OIA
mat T = J(3,5,.)

ttest dv_trustgov_std if longstring3==0, by (treat_oi_passed_MC1)
mat T[1,1] = r(mu_1)
mat T[1,2] = r(mu_2)
mat T[1,3] = r(mu_1) - r(mu_2)
mat T[1,4] = r(t)
mat T[1,5] = r(p)

ttest dv_trustrusppl_std if longstring3==0, by (treat_oi_passed_MC1)
mat T[2,1] = r(mu_1)
mat T[2,2] = r(mu_2)
mat T[2,3] = r(mu_1) - r(mu_2)
mat T[2,4] = r(t)
mat T[2,5] = r(p)

ttest dv_trust_all4_std if longstring3==0, by (treat_oi_passed_MC1)
mat T[3,1] = r(mu_1)
mat T[3,2] = r(mu_2)
mat T[3,3] = r(mu_1) - r(mu_2)
mat T[3,4] = r(t)
mat T[3,5] = r(p)


mat rownames T =  "Trust Russian Gov (2 items)" "Trust Russian Ppl (2 items)" "Trust (4 items)"  

	frmttable using cp_ttest_table3a.doc, statmat(T) varlabels replace ///
	ctitle("",  OIA=0, OIA=1, Difference, t-statistic, p-value)

	
** NIA
mat T = J(3,5,.)

ttest dv_trustgov_std if longstring3==0, by (treat_nia_passed_MC1)
mat T[1,1] = r(mu_1)
mat T[1,2] = r(mu_2)
mat T[1,3] = r(mu_1) - r(mu_2)
mat T[1,4] = r(t)
mat T[1,5] = r(p)

ttest dv_trustrusppl_std if longstring3==0, by (treat_nia_passed_MC1)
mat T[2,1] = r(mu_1)
mat T[2,2] = r(mu_2)
mat T[2,3] = r(mu_1) - r(mu_2)
mat T[2,4] = r(t)
mat T[2,5] = r(p)

ttest dv_trust_all4_std if longstring3==0, by (treat_nia_passed_MC1)
mat T[3,1] = r(mu_1)
mat T[3,2] = r(mu_2)
mat T[3,3] = r(mu_1) - r(mu_2)
mat T[3,4] = r(t)
mat T[3,5] = r(p)


mat rownames T =  "Trust Russian Gov (2 items)" "Trust Russian Ppl (2 items)" "Trust (4 items)"  

	frmttable using cp_ttest_table3b.doc, statmat(T) varlabels replace ///
	ctitle("",  NIA=0, NIA=1, Difference, t-statistic, p-value)

	
/** Table 4: The impact of Eastern Slavic identity affirmation and Ukrainian national 
identity affirmation on trust toward Russian government, Russian people, and overall trust **/

reg dv_trustgov_std treat_oi_passed_MC1  sd1_female sd2_age education income region_southeast b12_therm_russia  polpref_none ///
occuptn_professional occuptn_retired settlement_type convenient_rus ethn_rus [pweight = weight4] if longstring3==0 
eststo m1

reg dv_trustrusppl_std treat_oi_passed_MC1  sd1_female sd2_age education income region_southeast b12_therm_russia  polpref_none ///
occuptn_professional occuptn_retired settlement_type convenient_rus ethn_rus [pweight = weight4] if longstring3==0 
eststo m2

reg dv_trust_all4_std treat_oi_passed_MC1  sd1_female sd2_age education income region_southeast b12_therm_russia  polpref_none ///
occuptn_professional occuptn_retired settlement_type convenient_rus ethn_rus [pweight = weight4] if longstring3==0 
eststo m3


reg dv_trustgov_std treat_nia_passed_MC1  sd1_female sd2_age education income region_southeast b12_therm_russia  polpref_none ///
occuptn_professional occuptn_retired settlement_type convenient_rus ethn_rus [pweight = weight4] if longstring3==0 
eststo m4

reg dv_trustrusppl_std treat_nia_passed_MC1  sd1_female sd2_age education income region_southeast b12_therm_russia  polpref_none ///
occuptn_professional occuptn_retired settlement_type convenient_rus ethn_rus [pweight = weight4] if longstring3==0 
eststo m5

reg dv_trust_all4_std treat_nia_passed_MC1  sd1_female sd2_age education income region_southeast b12_therm_russia  polpref_none ///
occuptn_professional occuptn_retired settlement_type convenient_rus ethn_rus [pweight = weight4] if longstring3==0 
eststo m6


esttab m1 m2 m3 m4 m5 m6  ///
    using cp_ols_table4.tex, replace f label booktabs margin se(3) eqlabels(none) ///
	alignment(S S) collabels("\multicolumn{1}{c}{$\beta$ / SE}") ///
	star(* 0.05 ** 0.01) r2 aic bic
	
	

/** Table 5: Regional differences in trust between treated and control units **/

** OIA
mat T = J(6,5,.)

ttest dv_trustgov_std if longstring3==0  & region_southeast==0, by (treat_oi_passed_MC1)
mat T[1,1] = r(mu_1)
mat T[1,2] = r(mu_2)
mat T[1,3] = r(mu_1) - r(mu_2)
mat T[1,4] = r(t)
mat T[1,5] = r(p)

ttest dv_trustgov_std if longstring3==0  & region_southeast==1, by (treat_oi_passed_MC1)
mat T[2,1] = r(mu_1)
mat T[2,2] = r(mu_2)
mat T[2,3] = r(mu_1) - r(mu_2)
mat T[2,4] = r(t)
mat T[2,5] = r(p)


ttest dv_trustrusppl_std if longstring3==0  & region_southeast==0, by (treat_oi_passed_MC1)
mat T[3,1] = r(mu_1)
mat T[3,2] = r(mu_2)
mat T[3,3] = r(mu_1) - r(mu_2)
mat T[3,4] = r(t)
mat T[3,5] = r(p) 

ttest dv_trustrusppl_std if longstring3==0  & region_southeast==1, by (treat_oi_passed_MC1)
mat T[4,1] = r(mu_1)
mat T[4,2] = r(mu_2)
mat T[4,3] = r(mu_1) - r(mu_2)
mat T[4,4] = r(t)
mat T[4,5] = r(p)

ttest dv_trust_all4_std if longstring3==0  & region_southeast==0, by (treat_oi_passed_MC1)
mat T[5,1] = r(mu_1)
mat T[5,2] = r(mu_2)
mat T[5,3] = r(mu_1) - r(mu_2)
mat T[5,4] = r(t)
mat T[5,5] = r(p)

ttest dv_trust_all4_std if longstring3==0  & region_southeast==1, by (treat_oi_passed_MC1)
mat T[6,1] = r(mu_1)
mat T[6,2] = r(mu_2)
mat T[6,3] = r(mu_1) - r(mu_2)
mat T[6,4] = r(t)
mat T[6,5] = r(p)

mat rownames T =   "Trust Russian Gov (West-Center)" "Trust Russian Gov (Southeast)" ///
 "Trust Russian Ppl (West-Center)" "Trust Russian Ppl (Southeast)" ///
 "Trust (4 items, West-Center)"   "Trust (4 items, Southeast)" 


	frmttable using cp_table5_regions_OIA.doc, statmat(T) varlabels replace ///
	ctitle("",  OIA=0, OIA=1, Difference, t-statistic, p-value)


** NIA
mat T = J(6,5,.)

ttest dv_trustgov_std if longstring3==0  & region_southeast==0, by (treat_nia_passed_MC1)
mat T[1,1] = r(mu_1)
mat T[1,2] = r(mu_2)
mat T[1,3] = r(mu_1) - r(mu_2)
mat T[1,4] = r(t)
mat T[1,5] = r(p)

ttest dv_trustgov_std if longstring3==0  & region_southeast==1, by (treat_nia_passed_MC1)
mat T[2,1] = r(mu_1)
mat T[2,2] = r(mu_2)
mat T[2,3] = r(mu_1) - r(mu_2)
mat T[2,4] = r(t)
mat T[2,5] = r(p)

ttest dv_trustrusppl_std if longstring3==0  & region_southeast==0, by (treat_nia_passed_MC1)
mat T[3,1] = r(mu_1)
mat T[3,2] = r(mu_2)
mat T[3,3] = r(mu_1) - r(mu_2)
mat T[3,4] = r(t)
mat T[3,5] = r(p)

ttest dv_trustrusppl_std if longstring3==0  & region_southeast==1, by (treat_nia_passed_MC1)
mat T[4,1] = r(mu_1)
mat T[4,2] = r(mu_2)
mat T[4,3] = r(mu_1) - r(mu_2)
mat T[4,4] = r(t)
mat T[4,5] = r(p)

ttest dv_trust_all4_std if longstring3==0  & region_southeast==0, by (treat_nia_passed_MC1)
mat T[5,1] = r(mu_1)
mat T[5,2] = r(mu_2)
mat T[5,3] = r(mu_1) - r(mu_2)
mat T[5,4] = r(t)
mat T[5,5] = r(p)

ttest dv_trust_all4_std if longstring3==0  & region_southeast==1, by (treat_nia_passed_MC1)
mat T[6,1] = r(mu_1)
mat T[6,2] = r(mu_2)
mat T[6,3] = r(mu_1) - r(mu_2)
mat T[6,4] = r(t)
mat T[6,5] = r(p)

mat rownames T =   "Trust Russian Gov (West-Center)" "Trust Russian Gov (Southeast)" ///
 "Trust Russian Ppl (West-Center)" "Trust Russian Ppl (Southeast)" ///
 "Trust (4 items, West-Center)"   "Trust (4 items, Southeast)" 


	frmttable using cp_table5_regions_NIA.doc, statmat(T) varlabels replace ///
	ctitle("",  NIA=0, NIA=1, Difference, t-statistic, p-value)



/** Table 6: Regional differences in failure/refusal to engage with treatments **/


mat T = J(3,5,.)

ttest  refused_OI_treat if longstring3==0, by (region_southeast)
mat T[1,1] = r(mu_1)
mat T[1,2] = r(mu_2)
mat T[1,3] = r(mu_1) - r(mu_2)
mat T[1,4] = r(t)
mat T[1,5] = r(p)

ttest  refused_NIA_treat if longstring3==0 , by (region_southeast)
mat T[2,1] = r(mu_1)
mat T[2,2] = r(mu_2)
mat T[2,3] = r(mu_1) - r(mu_2)
mat T[2,4] = r(t)
mat T[2,5] = r(p)


ttest  refused_Control_treat if longstring3==0 , by (region_southeast)
mat T[3,1] = r(mu_1)
mat T[3,2] = r(mu_2)
mat T[3,3] = r(mu_1) - r(mu_2)
mat T[3,4] = r(t)
mat T[3,5] = r(p)


mat rownames T =  "Failure/Refusal to engage w/OIA" "Failure/Refusal to engage w/NIA" "Failure/Refusal to engage w/C"


	frmttable using cp_table6_refused.doc, statmat(T) varlabels replace ///
	ctitle("",  West-Center, Southeast, Difference, t-statistic, p-value)	
	
	
